<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ include file="/pages/common/header.jsp"%>
<script type="text/javascript">
var gridManager;
var _dialog;
var _initIds=[];
$(function (){
	PageLoader.initSearchPanel();
	gridManager = PageLoader.initGridPanel();
	var selectUrl="<%=contextPath %>/preprocess-PlaneInfo-listSourceSel.action";
	$.ajax({
			url: selectUrl,
			type: 'POST',
			dataType: 'json',
			error: function(){
				alert('渠道列表请求出错');
			},
			success: function(data){
				$('#attach_Hbase_Key').html('');
				$('#attach_Hbase_Key').append('<option value="">请选择渠道</option>' );
				$.each(data.listSource, function(idx, e){
					$('#attach_Hbase_Key').append('<option value='+e.hbaseKey+'>'+e.name+'</option>' );
				});
			}

		});
	
});

PageLoader = {
 //
 initSearchPanel:function(){
 //$("input[id^='executeTimeID_']").ligerDateEditor();//加载日期选择器
 },	
 initGridPanel:function(){
	  initIds=[];
	 selectedIdArr=[];
	 var g = $("#maingrid").ligerGrid({
         checkbox:true,
         height : '100%',
         rowHeight: 28,//行默认的高度
         headerRowHeight: 30,//表头行的高度
         pageSize : 20,
         onToPrev:next,
         onToNext:next,//条件查询方法
         columns: [
                   { display: '渠道', name: 'attachHbaseKey', width : 150, editor: { type: 'text' }},   
                   { display: '中文名称', name: 'grabChannel',width : 150,editor: { type: 'text' }},   
                   { display: '出发城市三字码', name: 'fromCity',width : 150,editor: { type: 'text' }},   
                   { display: '到达城市三字码', name: 'toCity',width : 150,editor: { type: 'text' }}, 
                   { display: '出发城市', name: 'fromCityName',width : 150,editor: { type: 'text' }}, 
                   { display: '到达城市', name: 'toCityName',width : 150,editor: { type: 'text' }}, 
        ], 
        isChecked: function (rowdata) {
      	  return rowdata.isSelected==1;
         },
        enabledEdit: false, clickToEdit: false,  
        parms : [
 				{name:"fetlDataVO.attachHbaseKey",value: '请选择'},
 				{name:"fetlDataVO.fromCity",value: $("#from_city").val()},
 				{name:"fetlDataVO.toCity",value: $("#to_city").val()},
                 ],
        url:"<%=contextPath %>/preprocess-AirLineConfig-pageJson.action",
        width: '100%',
        toolbar: { items: [
	        { id: "modify", text: '保存', click: itemclick, icon: 'modify' },
        ]
        }
    });
	 g.toggleCol("id",false);//隐藏id列
	 return g;
 }
}

//查询方法
function searchAction(){
     //form validate
   if(!Validator.Validate(document.getElementById("searchForm"),3))return;
     var param=$("#searchForm").serialize();
	  var initIds=[];
	g = $("#maingrid").ligerGrid({
        checkbox:true,
        height : '100%',
        rowHeight: 28,//行默认的高度
        headerRowHeight: 30,//表头行的高度
        pageSize : 20,
        onToPrev:next,
        onToNext:next,//条件查询方法
        newPage:'1',
        columns: [
                  { display: '渠道', name: 'attachHbaseKey', width : 150, editor: { type: 'text' }},   
                  { display: '中文名称', name: 'grabChannel',width : 150,editor: { type: 'text' }},   
                  { display: '出发城市三字码', name: 'fromCity',width : 150,editor: { type: 'text' }},   
                  { display: '到达城市三字码', name: 'toCity',width : 150,editor: { type: 'text' }}, 
                  { display: '出发城市', name: 'fromCityName',width : 150,editor: { type: 'text' }}, 
                  { display: '到达城市', name: 'toCityName',width : 150,editor: { type: 'text' }}, 
                ],
       isChecked: function (rowdata) {
    	  if (rowdata.isSelected==1){
    		  initIds.push(rowdata.id);
    		  return true;
    	  }
    	  return false;
       },
       enabledEdit: false, clickToEdit: false, 
       parms : [
				{name:"fetlDataVO.attachHbaseKey",value: $("#attach_Hbase_Key").val()},
				{name:"fetlDataVO.fromCity",value: $("#from_city").val()},
				{name:"fetlDataVO.toCity",value: $("#to_city").val()},
                ],
       url:"<%=contextPath %>/preprocess-AirLineConfig-pageJson.action",
       width: '100%',
       toolbar: { items: [
              	        { id: "modify", text: '保存', click: itemclick, icon: 'modify' },
            	        { line: true },
                      ]}
   });
	_initIds=initIds;
	//gridManager.loadServerData(param);/*执行服务器查询*/
}

/*分页条件查询参数*/
function next(){
	_initIds=[];
	gridManager.setOptions({
        parms: [
	   {name:"fetlDataVO.attachHbaseKey",value: $("#attach_Hbase_Key").val()},
		{name:"fetlDataVO.fromCity",value: $("#from_city").val()},
		{name:"fetlDataVO.toCity",value: $("#to_city").val()},
        ]
    });
}

function itemclick(item)
{
	switch (item.id) {
		case "modify":
			updateAction();
	        break;
	}
}

function updateAction(){
    var selectedRows = gridManager.getSelected();
	var selectedIdArr=[];
	$.each(gridManager.getCheckedRows(), function(index, element) {
		selectedIdArr.push(element.id);
	});
    var data = [{ name: 'initIds', value: _initIds.join(",") },{ name: 'selectedIds', value: selectedIdArr.join(",") }];
	 Koala.ajax({
 		async:true,
 		type : "POST",
 		url: "<%=contextPath %>/preprocess-AirLineConfig-update.action",
 		data:data,
 		dataType:'json',
 		success: function(data, textStatus){
 			if(data.result=="failed")//alert("不好意思！保存出错了，再试试吧~");
 			gridManager.loadData();
 		}
 		});
}

</script>
</head>
<body>
<div style="width:98%;height:100%;padding-left: 5px;">
<!-- search form -->
<form name="searchForm" id="searchForm" target="_self">
<table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>
<table width="800" border="0" style="margin:5px">
 <tr height="25px">
  <td width="16.6%">渠道:</td>
  <td width="16.7%">
    <select name="fetlDataVO.attachHbaseKey"  id="attach_Hbase_Key" class="select-common">
	  <option value="">请选择</option>
	</select> 
  </td>
  <td width="16.6%">出发城市三字码:</td>
  <td width="16.7%">
    <input name="fetlDataVO.fromCity" id="from_city" class="input-common"/> 
  </td>
  <td width="16.6%">到达城市三字码:</td>
  <td width="16.7%">
    <input name="fetlDataVO.toCity" id="to_city" class="input-common"/> 
  </td>
  
 </tr>
</table>	
</td>
    <td><input id="searchButton" type="button" class="btn-normal" onclick="searchAction()" value="查询" /></td>
  </tr>
</table>	
</form>
<!-- grid -->
<div id="maingrid"></div> 
</div>
</body>
</html>
